<?php
$this->breadcrumbs=array(
    'Looking For Jobs'
);
$jobsList = $data['data'];
$maxPage = $data['MaxPage'];
?>
<div class="">
    <h1>Looking For Jobs</h1>
    <!-- begin job list -->
    <div id="jobs-list">
        <?php foreach ($jobsList as $row) { ?>
        <div class="job-box">
            <div class="alert alert-primary">
                <img src="images/briefcase.png">
                <b><span><?= $row['Position'] ?></span>
                <span class="pull-right">Job ID : <?= $row['JobID'] ?></span></b>
            </div>
            <table class="table table-bordered">
                <tbody>
                    <tr><td class="rowheader">Location:</td><td><?= $row['ProvinceName'] ?></td></tr>
                    <tr><td class="rowheader">Gender:</td><td><?= $row['Sex'] == 'M'?'Male':($row['Sex'] == 'F'?'Female':'Undefined') ?></td></tr>
                    <tr><td class="rowheader">Age:</td><td><?= $row['Age'] ?> <?= $lang == 'en'?'year':'ปี' ?></td></tr>
                    <tr><td class="rowheader">Experience:</td><td><?= $row['Exp'] ?> <?= $lang == 'en'?'year':'ปี' ?></td></tr>
                    <tr><td class="rowheader">Salary:</td><td><?= $row['Salary'] ?> <?= $lang == 'en'?'bath':'บาท' ?></td></tr>
                    <tr><td class="rowheader">Descript:</td><td><?= $row['Descript'] ?></td></tr>
                </tbody>
            </table>
            <p class="text-center">
                <a href="index.php?lang=<?= $lang ?>&r=Jobs/Detail&id=<?= $row['JobID'] ?>" class="btn btn-large btn-primary" style="color: #fff;">
                    <i class="icon-list-alt"></i> Detail
                </a>
            </p>
        </div>
        <hr>
        <?php } ?>
    </div>
    <!-- End of job list -->
    <!--PAGE-->
    <?php
    if(isset($_GET['Keyword']) || isset($_GET['JobID']) || isset($_GET['Province'])){
        $url = "index.php?lang=en&r=Jobs/List&Keyword={$_GET['Keyword']}&JobID={$_GET['JobID']}&Province={$_GET['Province']}&";
    } else {
        $url = "index.php?lang=en&r=Jobs/List&";
    }
    GM::paging($url, $page, $maxPage); ?>  				 
    <!--End Contact form -->											 
</div>
<script>
    $(function(){
        // get value in form search
        $('#inputKeyword').val('<?= isset($_GET['Keyword']) ? $_GET['Keyword'] : '' ?>');
        $('#inputJobID').val('<?= isset($_GET['JobID']) ? $_GET['JobID'] : '' ?>');
        $('#inputProvince').val('<?= isset($_GET['Province']) ? $_GET['Province'] : '' ?>');
        
        //fill '-' cell(td)empty
        $('td').each(function(){
            if($(this).text()==''){
                $(this).text('-');
            }
        });
        
        $('#btn-search').click(function(){
            document.getElementById("formSearch").submit();
        });
    });
</script>